package main

import (
	"encoding/json"
	"fmt"
)

type User struct {
	Name string
	Age  int
	Sex  int `json:",omitempty"`
}

func main() {

	// 解码方式一
	txt := `{"name":"xingshun.yang","age":18,"sex":1}`
	var user User
	err := json.Unmarshal([]byte(txt), &user)

	if err != nil {
		print(err)
	}

	fmt.Printf("name:%s,age:%d,sex:%d", user.Name, user.Age, user.Sex)
}
